import requests


url = 'https://www.baidu.com'

# 创建请求头
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36'
}

# 发送请求
response = requests.get(url, headers=headers)

# 获取cookieJar对象
print(response.cookies)

# 将cookieJar转换为字典类型
cookies_dict = requests.utils.dict_from_cookiejar(response.cookies)

print(cookies_dict)

# 将cookies字典转换为cookieJar对象
cookies_jar = requests.utils.cookiejar_from_dict(cookies_dict)

print(cookies_jar)



